package com.mytrip.util.reqcache;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

public class InjectBeanSelfProcessor implements BeanPostProcessor{
	protected final Log log = LogFactory.getLog(getClass());

	public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException{
		if (bean instanceof BeanSelfAware) {
			log.debug("inject proxy：" + bean.getClass());
			BeanSelfAware myBean = (BeanSelfAware) bean;
			myBean.setSelf(myBean);
		}
		return bean;
	}

	public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException{
		return bean;
	}
}
